package cn.le.netty.messagepack;

import cn.le.netty.beans.Member;
import org.msgpack.MessagePack;
import org.msgpack.annotation.Message;
import org.msgpack.template.Templates;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class MesssagePackDemo {

    public static void main(String[] args) throws IOException {
        List<Member>  members = new ArrayList<Member>();
        for (int i = 0; i < 10; i++) {
            Member member = new Member();
            member.setMid("Mid "+i);
            member.setName("Hello - "+i);
            member.setAge(10);
            member.setSalary(1.1);
            members.add(member);
        }
        MessagePack msgPack = new MessagePack();
        //序列化
        byte[] data = msgPack.write(members);
        //反序列化
        List<Member> all = msgPack.read(data, Templates.tList(msgPack.lookup(Member.class)));
        System.out.println(all);

    }

}
